//
//  ByCellProductDetailFuncExtension.m
//  oc_knowledge
//
//  Created by pro on 17/1/18.
//  Copyright © 2017年 com.itboye. All rights reserved.
//

#import "ByCellProductDetailFuncExtension.h"

@interface ByCellProductDetailFuncExtension ()
@property (nonatomic, strong) UIView *line;
@end

@implementation ByCellProductDetailFuncExtension
{
    UIImageView *_iconImgView;
    UILabel     *_contentLabel;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = rgba(249, 249, 249, 1);
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        [self setupUI];
    }
    return self;
}
- (UIView *)line {
    
    if (!_line) {
        _line = [[UIView alloc] init];
        _line.backgroundColor = [UIColor colorWithWhite:0.9 alpha:1];
        [self.contentView addSubview:_line];
    }
    return _line;
}
- (void)setupUI {
    
    _iconImgView = [[UIImageView alloc] init];
    _iconImgView.image = [UIImage imageNamed:@"product_detail_checkmark"];
    [self.contentView addSubview:_iconImgView];
    
    _contentLabel = [[UILabel alloc] init];
    _contentLabel.adjustsFontSizeToFitWidth = YES;
    _contentLabel.font = FONT(14);
    _contentLabel.text = @"七天无理由退换";
    _contentLabel.textColor = [UIColor grayColor];
    _contentLabel.textAlignment = NSTextAlignmentLeft;
    [self.contentView addSubview:_contentLabel];
}
- (void)layoutSubviews {
    
    [super layoutSubviews];
    
    self.line.frame = CGRectMake(10, 0, self.width - 10 * 2, 0.5);
    self.line.bottom = self.height;
    
    _iconImgView.frame = CGRectMake(0, 0, 15, 15);
    _iconImgView.y = self.height / 2;
    _iconImgView.left = 10;
    
    _contentLabel.frame = CGRectMake(_iconImgView.right + 10, 0, 200, self.height);
}

@end
